#pragma once

#include <cmath>

#include "Common.h"

#include "vec2f.h"
#include "vec3f.h"
#include "vec4f.h"
#include "mat3f.h"
#include "mat4f.h"

namespace davmath { class quaternionf; };
using namespace davmath;

/* * * * * * * * * *
 * quaternionf
 * Author:	David Ogle
 * Date:	26/03/2012
 * quaternion of float values
 * * * * * * * * * */

class davmath::quaternionf
{
public:

	// Data
	union {
		float x, y, z, w;
	};

	// Constructor
	quaternionf(void) { x = y = z = 0.0f; w = 1.0f; };
	quaternionf(float x, float y, float z, float w);	// From raw quaternion values
	quaternionf(float pitch, float yaw, float roll);	// From Euler angles
	quaternionf(const vec3f &axis, float angle);		// From Axis/Angle
	quaternionf(const mat4f &m);						// From rotation matrix
	// Destructor
	~quaternionf(void) { };


	// Static quaternion functions
	static quaternionf	eulerAnglesToQuaternion(float pitch, float yaw, float roll);
	static quaternionf	axisAngleToQuaternion(const vec3f &vector, float degrees);
	//static void			rotatePointByQuaternion(const quaternionf &q, vec3f &point);
	static quaternionf	fromMatrix(const mat4f &m);
	static float		dot(const quaternionf &a, const quaternionf &b);



	// Quaternion functions
	void			normalize();
	mat4f			toMatrix()		const;
	quaternionf		conjugate()		const;
	void			generatew();



	// Quaternion operators
	quaternionf	operator*(const quaternionf &a) const;
	quaternionf operator*(const vec3f &a) const;

};

